 package server.maps;

 import java.awt.Point;
 import java.awt.Rectangle;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 import tools.Pair;

 public class MapleNodes
 {
   private final Map<Integer, MapleNodeInfo> nodes;
   private final Map<Integer, List<Integer>> nodes12;
   private final List<Rectangle> areas;
   private final List<MaplePlatform> platforms;
   private final List<MonsterPoint> monsterPoints;
/*  22 */   private int nodeStart = -1; private final List<Integer> skillIds; private final List<Pair<Integer, Integer>> mobsToSpawn; private final List<Pair<Point, Integer>> guardiansToSpawn; private final List<Pair<String, Integer>> flags; private final List<DirectionInfo> directionInfo; private final int mapid;
/*  23 */   private int nodeEnd = -1;
   private boolean firstHighest = true;

   public MapleNodes(int mapid) {
/*  27 */     this.nodes = new LinkedHashMap<>();
/*  28 */     this.nodes12 = new TreeMap<>();
/*  29 */     this.areas = new ArrayList<>();
/*  30 */     this.platforms = new ArrayList<>();
/*  31 */     this.skillIds = new ArrayList<>();
/*  32 */     this.directionInfo = new ArrayList<>();
/*  33 */     this.monsterPoints = new ArrayList<>();
/*  34 */     this.mobsToSpawn = new ArrayList<>();
/*  35 */     this.guardiansToSpawn = new ArrayList<>();
/*  36 */     this.flags = new ArrayList<>();
/*  37 */     this.mapid = mapid;
   }

   public void setNodeStart(int ns) {
/*  41 */     this.nodeStart = ns;
   }

   public void setNodeEnd(int nodeEnd) {
/*  45 */     this.nodeEnd = nodeEnd;
   }

   public Map<Integer, List<Integer>> getNodes12() {
/*  49 */     return this.nodes12;
   }

   public void addDirection(int key, DirectionInfo d) {
/*  53 */     this.directionInfo.add(key, d);
   }

   public DirectionInfo getDirection(int key) {
/*  57 */     if (key >= this.directionInfo.size()) {
/*  58 */       return null;
     }
/*  60 */     return this.directionInfo.get(key);
   }

   public List<Pair<String, Integer>> getFlags() {
/*  64 */     return this.flags;
   }

   public void addFlag(Pair<String, Integer> f) {
/*  68 */     this.flags.add(f);
   }

   public void addNode(MapleNodeInfo mni) {
/*  72 */     this.nodes.put(Integer.valueOf(mni.key), mni);
   }

   public Collection<MapleNodeInfo> getNodes() {
/*  76 */     return new ArrayList<>(this.nodes.values());
   }

   public MapleNodeInfo getNode(int index) {
/*  80 */     int i = 1;
/*  81 */     for (MapleNodeInfo x : getNodes()) {
/*  82 */       if (i == index) {
/*  83 */         return x;
       }
/*  85 */       i++;
     }
/*  87 */     return null;
   }

   public boolean isLastNode(int index) {
/*  91 */     return (index == this.nodes.size());
   }

   private int getNextNode(MapleNodeInfo mni) {
/*  95 */     if (mni == null) {
/*  96 */       return -1;
     }
/*  98 */     addNode(mni);









/* 108 */     int ret = -1;
/* 109 */     for (Iterator<Integer> iterator = mni.edge.iterator(); iterator.hasNext(); ) { int i = ((Integer)iterator.next()).intValue();
/* 110 */       if (!this.nodes.containsKey(Integer.valueOf(i))) {
/* 111 */         if (ret != -1 && (this.mapid / 100 == 9211204 || this.mapid / 100 == 9320001)) {
/* 112 */           if (!this.firstHighest) {
/* 113 */             ret = Math.min(ret, i); continue;
           }
/* 115 */           this.firstHighest = false;
/* 116 */           ret = Math.max(ret, i);

           break;
         }

/* 121 */         ret = i;
       }  }


/* 125 */     mni.nextNode = ret;
/* 126 */     return ret;
   }

   public void sortNodes() {
/* 130 */     if (this.nodes.size() <= 0 || this.nodeStart < 0) {
       return;
     }
/* 133 */     Map<Integer, MapleNodeInfo> unsortedNodes = new HashMap<>(this.nodes);
/* 134 */     int nodeSize = unsortedNodes.size();
/* 135 */     this.nodes.clear();
/* 136 */     int nextNode = getNextNode(unsortedNodes.get(Integer.valueOf(this.nodeStart)));
/* 137 */     while (this.nodes.size() != nodeSize && nextNode >= 0) {
/* 138 */       nextNode = getNextNode(unsortedNodes.get(Integer.valueOf(nextNode)));
     }
   }

   public void addMapleArea(Rectangle rec) {
/* 143 */     this.areas.add(rec);
   }

   public List<Rectangle> getAreas() {
/* 147 */     return new ArrayList<>(this.areas);
   }

   public Rectangle getArea(int index) {
/* 151 */     return getAreas().get(index);
   }

   public void addPlatform(MaplePlatform mp) {
/* 155 */     this.platforms.add(mp);
   }

   public List<MaplePlatform> getPlatforms() {
/* 159 */     return new ArrayList<>(this.platforms);
   }

   public List<MonsterPoint> getMonsterPoints() {
/* 163 */     return this.monsterPoints;
   }

   public void addMonsterPoint(int x, int y, int fh, int cy, int team) {
/* 167 */     this.monsterPoints.add(new MonsterPoint(x, y, fh, cy, team));
   }

   public void addMobSpawn(int mobId, int spendCP) {
/* 171 */     this.mobsToSpawn.add(new Pair(Integer.valueOf(mobId), Integer.valueOf(spendCP)));
   }

   public List<Pair<Integer, Integer>> getMobsToSpawn() {
/* 175 */     return this.mobsToSpawn;
   }

   public void addGuardianSpawn(Point guardian, int team) {
/* 179 */     this.guardiansToSpawn.add(new Pair(guardian, Integer.valueOf(team)));
   }

   public List<Pair<Point, Integer>> getGuardians() {
/* 183 */     return this.guardiansToSpawn;
   }

   public List<Integer> getSkillIds() {
/* 187 */     return this.skillIds;
   }

   public void addSkillId(int z) {
/* 191 */     this.skillIds.add(Integer.valueOf(z));
   }

   public static class MapleStopInfo
   {
     public String scriptName;
     public int stopDuration;
     public int sayTic;
     public int chatBalloon;
     public boolean isWeather;
     public boolean isRepeat;
     public boolean isRandom;
/* 203 */     public List<Pair<String, String>> sayInfo = new ArrayList<>();

     public MapleStopInfo(String scriptName, int stopDuration, int sayTic, int chatBalloon, boolean isWeather, boolean isRepeat, boolean isRandom, List<Pair<String, String>> sayInfo) {
/* 206 */       this.scriptName = scriptName;
/* 207 */       this.stopDuration = stopDuration * 1000;
/* 208 */       this.sayTic = sayTic;
/* 209 */       this.chatBalloon = chatBalloon;
/* 210 */       this.isWeather = isWeather;
/* 211 */       this.isRepeat = isRepeat;
/* 212 */       this.isRandom = isRandom;
/* 213 */       this.sayInfo = sayInfo;
     }
   }

   public static class MapleNodeInfo
   {
     public final int node;
     public final int key;
     public final int x;
     public final int y;
     public final int attr;
     public final List<Integer> edge;
/* 225 */     public int nextNode = -1;
     public MapleNodes.MapleStopInfo stopInfos;

     public MapleNodeInfo(int node, int key, int x, int y, int attr, List<Integer> edge, MapleNodes.MapleStopInfo stopInfos) {
/* 229 */       this.node = node;
/* 230 */       this.key = key;
/* 231 */       this.x = x;
/* 232 */       this.y = y;
/* 233 */       this.attr = attr;
/* 234 */       this.edge = edge;
/* 235 */       this.stopInfos = stopInfos;
     }
   }

   public static class DirectionInfo
   {
     public final int x;
     public final int y;
     public final int key;
     public final boolean forcedInput;
/* 245 */     public final List<String> eventQ = new ArrayList<>();

     public DirectionInfo(int key, int x, int y, boolean forcedInput) {
/* 248 */       this.key = key;
/* 249 */       this.x = x;
/* 250 */       this.y = y;
/* 251 */       this.forcedInput = forcedInput;
     }
   }

   public static class MaplePlatform
   {
     public final String name;
     public final int start;
     public final int speed;
     public final int x1;
     public final int y1;
     public final int x2;
     public final int y2;
     public final int r;
     public final List<Integer> SN;

     public MaplePlatform(String name, int start, int speed, int x1, int y1, int x2, int y2, int r, List<Integer> SN) {
/* 268 */       this.name = name;
/* 269 */       this.start = start;
/* 270 */       this.speed = speed;
/* 271 */       this.x1 = x1;
/* 272 */       this.y1 = y1;
/* 273 */       this.x2 = x2;
/* 274 */       this.y2 = y2;
/* 275 */       this.r = r;
/* 276 */       this.SN = SN;
     }
   }

   public static class MonsterPoint
   {
     public final int x;
     public final int y;
     public final int fh;
     public final int cy;
     public final int team;

     public MonsterPoint(int x, int y, int fh, int cy, int team) {
/* 289 */       this.x = x;
/* 290 */       this.y = y;
/* 291 */       this.fh = fh;
/* 292 */       this.cy = cy;
/* 293 */       this.team = team;
     }
   }
 }


/* Location:              C:\PGX\Server.jar!\server\maps\MapleNodes.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */